package com.cjt.controller;

import cn.hutool.core.map.MapUtil;
import com.cjt.common.lang.R;
import com.cjt.pojo.User;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.security.Principal;
import java.util.List;

@RestController
@RequestMapping("/sys/menu")
public class MenusController extends BaseController{

    @GetMapping("/nav")
    public R nav(Principal principal) {
        //获取权限
        User user = userService.getByUsername(principal.getName());
        String userAuthorityInfo = userService.getUserAuthorityInfo(user.getId());
        String[] strArry = userAuthorityInfo.split(",");
        //获取菜单内容
        List<Long> navMenuIds = userMapper.getNavMenuIds(user.getId());
        return R.success(MapUtil.builder()
                .put("menuList",strArry)
                .map());
    }




}
